import javafx.event.ActionEvent;

import javax.swing.*;
import java.awt.event.ActionListener;

public class RegisterPanel extends JPanel {
    private JTextField usernameField;
    private JPasswordField passwordField;
    private JButton registerButton;

    public RegisterPanel() {
        usernameField = new JTextField(20);
        passwordField = new JPasswordField(20);
        registerButton = new JButton("Register");


        registerButton.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent e) {
                String username = usernameField.getText();
                String password = new String(passwordField.getPassword());

                if (DBHelper.registerUser(username, password)) {
                    JOptionPane.showMessageDialog(RegisterPanel.this, "Registration successful!");
                } else {
                    JOptionPane.showMessageDialog(RegisterPanel.this, "Registration failed. User already exists.");
                }
            }
        });

        add(new JLabel("Username:"));
        add(usernameField);
        add(new JLabel("Password:"));
        add(passwordField);
        add(registerButton);
            }



    }

public class Test {

}
